package com.example.web.controller;

import com.example.api.Result;
import com.example.api.dto.WwwDTO;
import com.example.api.service.WwwService;
import com.example.api.vo.WwwVO;
import com.sun.org.apache.regexp.internal.RE;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;



@Slf4j
@Controller
@RequestMapping(value = "/www")
public class WwwController {

    @Reference
    private WwwService wwwService;

    @RequestMapping(value = "/{id}" , method = RequestMethod.GET)
    @ResponseBody
    public String getWww(@PathVariable("id") Integer id){
        String resultString = wwwService.findById(id);
        return resultString;
    }

    /**
     * 新增权限
     * @return
     */
    @RequestMapping(value = "/insert" , method = RequestMethod.POST)
    @ResponseBody
    public Result insert(@RequestBody WwwVO wwwVO){
        return wwwService.insert(wwwVO);
    }


    /**
     * 批量新增
     * @param
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/save" ,method = RequestMethod.POST)
    public Long save(@RequestBody @Validated WwwDTO wwwDTO){
        return wwwService.save(wwwDTO);
        }



}